﻿@model Thread

@RenderPage(TPath("Views/Shared/_ServerContainer.cshtml", "wow"))

<div class="homepage-news-wrapper">
    <div id="blog">
		<div class="blog-inner">
            @if (Model != null)
            {
            <h3 class="blog-title"> @Model.Title </h3>
            <div class="by-line">
                <a href="@Model.Category.CategoryUrl">@Model.Category.CategoryName</a>
                <span class="spacer"></span> @Model.LastModify.ToLocalDateTimeString()
                <a href="#comments" class="comments-link">
                    @Model.PostCount
                </a>
            </div>
            <div class="details">@Html.Raw(Model.Body)</div>
            }
            else
            { 
                <div class="details">@Local("ThreadView.ThreadNotFound")</div>
            }
        </div>
    </div>
</div>

@if (Model != null && Model.AllowedApply)
{            
<a name="comments"></a>
<div id="page-comments">
    <div class="page-comment-interior">
        <h3>@Local("ThreadView.Comments") （@Model.PostCount）</h3>
		<div class="comments-container">
            <div style="text-align:center; margin-bottom:20px;">
                @if (IsAuthenticated)
                {
                <a class="ui-button button1 " href="#reply">
		            <span>
			            <span>回复主题</span>
		            </span>
	            </a>
                }
                else 
                { 
                <a class="ui-button button1 " href="javascript:void(0);" onclick="return openModal('@GetUrl("logon")', 300);">
		            <span>
			            <span>回复主题</span>
		            </span>
	            </a>
                }
            </div>

            @if (ViewBag.Posts != null)
            {
                foreach (var post in ViewBag.Posts as List<Post>)
                {
                <div class="comment mbottom">
                    <table class="comment-table" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="comment-left">
                                <img class="avatar" src="@post.User.Avatar" />
                            </td>
                            <td class="comment-content">
                                <div><strong>@post.User.NickName</strong> <span class="time"><a href="#">@post.CreateDate.ToLocalDateTimeString()</a></span></div>
                                @Html.Raw(post.FormattedBody)
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="comment-content tright">
                            @if (Permission.AllowComments == true)
                            {
                                @Html.AjaxLink(HttpAction.Delete, "Delete", new { postid = post.PostID }, null, null, null, SiteUrls.PostViewUrl)
                            }
                            </td>
                        </tr>
                    </table>
                    <span class="clear"></span>
                </div>
                }
            }
        </div>
        
        @if (IsAuthenticated)
        {
		<div class="comments-container">
            <a name="reply"></a>
            <div class="comment">
                <div style="line-height:22px;">
                    <form method="post">
                        <div>内容：</div>
                        <input type="hidden" value="@Model.ThreadID" name="ThreadID" />
                        <textarea id="Body" name="Body" class="txt"></textarea>
                        <div>（@GLocal("Comments.Summary", Permission.CommentLength)）</div>
                        <div style="text-align:center;">
                            <button class="ui-button button1" type="submit">
		                        <span>
			                        <span>回复主题</span>
		                        </span>
	                        </button>
                        </div>
                    </form>
                </div>
                <span class="clear"></span>
            </div>
        </div>
        }
    </div>
</div>
}